package com.gitee.deeround.javaprotect.tool;

/**
 * @author: chejiangyi
 * bsf 基础错误定义
 * @version: 2019-06-12 14:34
 **/
public class ProtectException extends RuntimeException {

    private Throwable source;

    public ProtectException(Throwable exp) {
        super(exp);
        this.source = exp;
    }

    public ProtectException(String message) {
        super(message);
    }

    public ProtectException(String message, Throwable cause) {
        super(message, cause);
        this.source = cause;
    }

    public Throwable getSource() {
        if (this.source == null) {
            return null;
        }
        if (this.source instanceof ProtectException) {
            return ((ProtectException) this.source).getSource();
        }
        return source;
    }
}
